<template>
	<view class="connect_dis">
		<back title=" "></back>
		<view class="shen_box">
			<view class="shen_box_left">
				<span class="shen_box_left1">申请分销</span>
				<span class="shen_box_left2">成为分销商,躺着也能赚钱</span>
			</view>
			<image style="width: 294rpx;" src="../../static/vip/icon_52.png" mode="widthFix"></image>
		</view>
		<view class="shen_info">
			<image style="width:332rpx; height: 44rpx; margin-bottom: 26rpx;" src="../../static/vip/icon_53.png" mode=""></image>
			<image style="width: 92rpx;" src="../../static/vip/icon_52.png" mode="widthFix"></image>
			<view class="shen_info_tui">
				推荐人:<span class="shen_info_tui" style=" margin-left: 20rpx;">{{info.user_name}}</span>
			</view>
		</view>
		<view class="shen_info" style="margin-top: 25rpx;">
			<view class=" log_jia">
				<view class="connect_dis_left"></view>
				<span class="connect_dis_center">加盟须知</span>
				<view class="connect_dis_right"></view>
			</view>
			<view class="connect_list">
				<view class="connect_list_item">
					<image style="width: 28rpx; height: 28rpx;margin-right: 16rpx;" src="../../static/vip/icon_36.png" mode=""></image>
					<span>邀请他人成为客户，拿一级佣金。</span>
				</view>
				<view class="connect_list_item">
					<image style="width: 28rpx; height: 28rpx;margin-right: 16rpx;" src="../../static/vip/icon_36.png" mode=""></image>
					<span>订单完成后结算，每月20日统一结算发放。</span>
				</view>
			</view>
			
		</view>
		<!-- <u-notice-bar mode="vertical" :list="list"></u-notice-bar> -->
		<!-- <view v-if="info" class="info_box">
			<H4>成为分销商,躺着也能赚钱</H4>
			<view class="tui_box_1">
				<view class="tui_box_1_title">
					申请信息
				</view>
				<view class="tui_box_1_title2">
					推荐人
					<span style="color:#333; margin-left: 20rpx;">{{info.user_name}}</span>
				</view>
			</view>
			<view class="tui_box_1">
				<view class="tui_box_1_title">
					加盟须知
				</view>
				<view class="tui_box_1_title2" style="padding-left: 20rpx;">
					{{info.desc}}
				</view>
			</view>
		</view> -->
		<view class="" style="position: fixed;width: 100%; display: flex; align-items: center; justify-content: center; bottom: 70rpx;left: 0;">
			<u-button :ripple="true" ripple-bg-color="rgba(0,0,0,.2)" @click="submit" class="btn_submit2" shape="circle" type="warning">立即加盟</u-button>
		</view>
		
	</view>
</template>

<script>
		import back from '@/componts/back.vue';
		export default {
			components:{
				back
			},
		data() {
			return {
				title:'',
				list:['加盟分销商下单有钱赚~'],
				dataList:[],
				uid:0,
				info:{}
			}
		},
		onLoad(data) {
			this.title = '申请分销'
			if(data.uid){
				this.uid = data.uid
				uni.setStorageSync('other_uid', data.uid)
				this.getInfo(data.uid)
			}else{
				this.uid = uni.getStorageSync('other_uid')
				if(this.uid){
					this.getInfo(this.uid)
					// this.customer()
				}else{
					this.getInfo()
				}
				
				
			}
		},
		onShow() {
			var style =  uni.getStorageSync('style')
			style = JSON.parse(style)
			this.style = style
		},
		
		
		methods: {
			back(){
				uni.navigateTo({
					url:'/pages/self/distribution'
				})
			},
			getInfo(uid){
				var data = {
					uid:this.uid
				}
				this.$wqzApi.UserDealer_config_detail(data).then(res=>{
					this.info = res.data
					// if(this.uid){
					// 	this.submit()
					// }
				})
			},
			
			customer(){
				var data = {
					uid:this.uid
				}
				this.$wqzApi.UserDealer_customer(data).then(res=>{
					uni.showToast({
						title:`已成为${this.info.user_name}客户`,
						icon:'none'
					})
					uni.setStorageSync('other_uid', '')
				}).catch(err=>{
					uni.setStorageSync('other_uid', '')
				})
			},
			submit(){
				var data = {
					recommend_uid:this.uid
				}
				this.$wqzApi.UserDealer_add(data).then(res=>{
					if(this.uid){
						uni.setStorageSync('other_uid', null)
					}
					uni.showToast({
						title:'申请成功',
						icon:'none'
					})
				})
			},
		}
	}
</script>
<style lang="scss" scoped>
	@import url(./Apply_distribution.css);
</style>
